- 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.5k
 
feat: Handle glob pattern in watch configuration path #12557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
        
          
                go.mod
              
                Outdated
          
        
      | sigs.k8s.io/yaml v1.4.0 // indirect | ||
| ) | ||
| 
               | 
          ||
| replace github.com/compose-spec/compose-go/v2 v2.4.8 => ../compose-go | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @jhrotko 👋
You need to replace compose-go with a version of your fork 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coucou @glours ! 😉
Done
| 
           LGTM just as a side not, support for multiple paths in watch definition could also be implemented as some syntaxic sugar in compose-go, i.e. while parsing we translate multiple  This would avoid changes to compose and keep logic simpler (especially to later introduce support for match patterns). wdyt?  | 
    
          
 Hey @ndeloof  :) Could you confirm that when you say sugar syntax do you mean to represent the   | 
    
| 
           Nope, I mean  i.e.    develop:
      watch:
        - path: [api, other]
           action: rebuildwould be cannonical-ized into:    develop:
      watch:
        - path: api
           action: rebuild
        - path: other
           action: rebuildActually I see more benefits in pattern support vs multiple paths, which sounds a corder case to me  | 
    
          
 I see, I will make this changes. The pattern matching can translate into multiple files though so these features are actually related. And can be annoying to define multiple watch rules for the same action (rebuild and restart)  | 
    
          
 I don't get this. A basic path matches multiple files (anything under folder matches). A pattern is just more restrictive. This is unrelated to multiple values in  My initial thoughts to implement this feature was to introduce an  File  .. but with a more comprehensible syntax :P  | 
    
| 
           so imagine the case where the target is a file in this case, we need to be careful and through some error. During validation, when target is a file, compose-go needs to assert the relation 1 to 1 is true or else it will have a weird behaviour in this case. That is why I was assuming path could be treated as a []string to be easier to validate this case. The presented example I would assume it should throw an error or show a warning at least as multiple files can overwrite one file in the container  | 
    
| 
           target can't be a file, MUST be a folder. If you want to sync with file  Remember   | 
    
Signed-off-by: Joana Hrotko <[email protected]>
Signed-off-by: Joana Hrotkó <[email protected]>
3e40780    to
    40bcdcc      
    Compare
  
    Signed-off-by: Joana Hrotkó <[email protected]>
40bcdcc    to
    4396577      
    Compare
  
    | 
           Closing this PR as we merged #12584  | 
    
What I did
This PR enables watch configuration to handle glob patterns in watch configuration
pathkeyword.Example:
In order to watch files under some glob pattern, during watch initialisation we register the anchor folder for the glob pattern (ex.:
api). When a file event is received, is going to check if any of the watch rules matches the pattern. In this case, an additional rule pattern was added towatchRule--globPattern-- in order to fulfil this verification.Note: Some of these changes require changes made in compose-spec/compose-go#740. For more details please check this PR.
Related issue
This PoC is based on the request
(not mandatory) A picture of a cute animal, if possible in relation to what you did